<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        x: {{x}}
        y: {{y}}
    </div>
    <script type="module">
        import { createApp,reactive,toRefs} from './node_modules/vue/dist/vue.esm-browser.js'
        const app = createApp({
          setup(){
            const getPosition = ()=>{
                // 解构之后，代理对象失效，仍然不是响应式的
                // return reactive({x:0,y:0})
                // toRefs 可以把响应式对象中的所以属性也转换为响应式的，需要传入代理对象
                return toRefs(reactive({x:0,y:0}))
            }
            const {x,y} = getPosition()
            return{ x,y }
          },
          mounted(){
              this.x = 100
          }
        })
        app.mount('#app')
    </script>
</body>

</html>